

	var win;
	function createLoginWindow(){
		
   				var mainCmpPanel = new Ext.FormPanel({
   					id			: 'mainCmpPanel',
   					autoHeight	: true,
   					autoWidth	: true,
   					layout 		: 'form',
   					padding		: '5px',
   					items		: [
   					     		    {
   					     		   		xtype		: 'textfield',
   					     		   		//id			: 'loginId',
   					     		   		name		: 'j_username',
   					     		   		fieldLabel	: 'Login Id',
   					     		   		width		: '96%'
   					     		    },
   					     		    {
   					     		    	xtype		: 'textfield',
   					     		    	inputType	: 'password',
   					     		    	//id			: 'password',
   					     		    	name		: 'j_password',
   					     		    	fieldLabel	: 'Password',
   					     		    	width		: '96%'
   					     		    }
   					     		   ],
					buttons		 : [
					       		   	 { 	
					       		    	xtype		: 'button',
					       		    	id			: 'loginButton',
					       		    	text		: 'Login',
					       		    	width		: 50,
					       		    	handler		: verifyMe,
					       		    	formBind	: true
					       		    				  
					       		   	 },
					       		   	 {
					       		   		 xtype		: 'button',
					       		   		 id			: 'resetButton',
					       		   		 text		: 'Reset',
					       		   		 width		: 50,
					       		   		 handler	: clear
					       		   	 }
					       		    ],
					keys		 : [
					    		    	{
					    		    		key		: [Ext.EventObject.ENTER], handler : function(){
					    		    												verifyMe();
					    		    											}
					    		    	}
					    		    ] 	
   				});
   				
   				win = new Ext.Window({
   					title	: 'Login',
   					height  : 130,
   					width	: 350,
   					closable: false,
   					items	: [mainCmpPanel]
   				});

   				win.show();
   				return win;
	}
   				
   				//functions
				/*
   				function verifyMe(){
                  var formPanel = Ext.getCmp('mainCmpPanel');
          	      formPanel.el.mask('Please wait', 'x-mask-loading');                 
        	      var values = formPanel.getForm().getValues();
        	      var data = Ext.encode(values);
        	       
        	      Ext.Ajax.request({
            		   url		: 'login/verify',
            		   method	: 'POST',
            		   waitMsg	: 'Login in progress...',
            		   success	: function(result, request){
            			   			var jsonData = Ext.util.JSON.decode(result.responseText);
            			   			//alert(jsonData.data);
            			   			if(jsonData.data == 'home'){
										window.location = jsonData.data;// jsonData.data is the name of target page
            			   			}else{
            			   				Ext.Msg.alert('Alert','Invalid LoginId or Password!');
            			   				formPanel.el.unmask();
            			   			}
		     			   		  },
            		   failure 	: function(result){
            			   			   var jsonData = Ext.util.JSON.decode(result.responseText);
			            			   Ext.Msg.show({
			                               title	: 'Result',
			                               msg		: jsonData.errors.reason,
			                               buttons	: Ext.Msg.OK,
			                               icon		: Ext.Msg.ERROR
			            			   });
            			   			formPanel.el.unmask();
            			   		  },
            		   jsonData : data   		  
            	   });
            	 };
            	 */
	
				function verifyMe(){
					var formPanel = Ext.getCmp('mainCmpPanel');
					formPanel.getForm().submit({
	    					 method	: 'POST',
	    					 waitMsg: 'Processing...',
	    					 url	: 'http://localhost:8080/crm-webapp/j_spring_security_check',
	    					 success: function(){
	    						 			
	    						 			Ext.Msg.alert('Status', 'Login Successfully!', function(btn, text){
	    						 				if(btn == 'ok'){
	    						 					window.location='home';
	    						 				}
	    						 			});
	    						 			
	    						 			//Ext.Msg.alert('Message','Successful!');
	    					 			},
	    					 failure : function(form, action){
	    						 			
	    						 			if(action.failureType = 'server'){
	    						 				obj = Ext.util.JSON.decode(action.response.responseText);
	    						 				Ext.Msg.alert('Login Failed!', obj.errors.reason);
	    						 			}else{
	    						 			 Ext.Msg.alert('Warning!', 'Authentication server is unreachable : ' + action.response.responseText);
	    						 			}
	    						 			
	    						 			//Ext.Msg.alert('Error','Failure!');
	    					 		    }			
	    				  });
				};
            	 
            	 function clear(){
            		 Ext.getCmp('mainCmpPanel').getForm().reset();
            	 };
	 
   			